#!/usr/bin/env php
<?php

declare(strict_types=1);

/*
 * This file is part of the forcodepoem package.
 *
 * The PHP Application Created By Code Poem. <Query Yet Simple>
 * (c) 2018-2099 http://forcodepoem.com All rights reserved.
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

use Common\App\Exception\Runtime;
use Common\App\Kernel;
use Common\App\KernelConsole;
use Leevel\Bootstrap\Project;
use Leevel\Kernel\IKernel;
use Leevel\Kernel\IKernelConsole;
use Leevel\Kernel\IRuntime;

/**
 * ---------------------------------------------------------------
 * Composer
 * ---------------------------------------------------------------.
 *
 * 用于管理 PHP 依赖包
 */
require_once __DIR__.'/vendor/autoload.php';

/**
 * ---------------------------------------------------------------
 * 创建项目
 * ---------------------------------------------------------------.
 *
 * 注册项目基础服务
 */
$project = Project::singletons(__DIR__);

$project->singleton(IKernel::class, Kernel::class);

$project->singleton(IKernelConsole::class, KernelConsole::class);

$project->singleton(IRuntime::class, Runtime::class);

/**
 * ---------------------------------------------------------------
 * 执行项目
 * ---------------------------------------------------------------.
 *
 * 根据内核调度请求返回响应
 */
$kernel = $project->make(IKernelConsole::class);

$status = $kernel->handle();

$kernel->terminate($status);

exit($status);
